// 统一管理用户相关的接口
import request from '@/utils/request'
import type {loginFormData, userInfoResponseData} from './type'

// 项目用户相关的请求地址
enum API {
    LOGIN_URL = '/api/users/login',
    USERINFO_URL = '/api/users/info',
    LOGOUT_URL = '/api/users/logout',
    REGISTER_URL = '/api/users/register',
    USERLIST_URL = '/api/users',
    USERBYID_URL = '/api/users/',
    USERSAVE_URL = '/api/users/save',
    USERDELETE_URL = '/api/users/',
}

//登录接口
export const reqLogin = (data: loginFormData) => request.post(API.LOGIN_URL, data)
//获取用户信息
export const reqUserInfo = () => request.get<any, userInfoResponseData>(API.USERINFO_URL)
// 保存用户信息
export const reqSaveUserInfo = (data: any) => request.post<any, any>(API.USERSAVE_URL, data)
// 获取用户详细信息
export const reqUserInfoById = (id: number) => request.get<any, userInfoResponseData>(API.USERBYID_URL + id)
// 删除用户
export const reqDeleteUser = (id: number) => request.delete<any, any>(API.USERDELETE_URL + id)
//退出登录
export const reqLogout = () => request.post<any, any>(API.LOGOUT_URL)
//注册接口
export const reqRegister = (data: any) => request.post(API.REGISTER_URL, data)
//获取用户列表
export const reqGetUserList = (params: any) => request.get(API.USERLIST_URL, {params})